# ********************************************
# * Automatic Script - Run all               *
# * Authors: André Bannwart Perina           *
# *          Antonio Canabrava Fraideinberze *
# *          Willian Felipe Lopes da Silva   *
# ******************************************** 

if [ $# -ne 13 ]; then
    echo "Usage: $0 loopTimes portNumber deltaSize numIters startIndex numProc filesPrefix outputFile tournamentSize percentage crossOver mutation beta"
    exit
fi

echo "Creating all folders..."
mkdir deltaFiles
mkdir fitnessFiles
mkdir stats

echo "Compiling all programs..."
make bin/generate
make bin/main
make bin/gapFillerBadKiller
make bin/histogramiser
make bin/tournament
make bin/fit

echo "1. Generating individuals..."
./bin/generate $3 $4 $5

./runCrossoverAndMutation.sh $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} 1

echo "Copying first generation..."
cp deltaFiles/generation0/file_* deltaFiles
./runCrossoverOnly.sh $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} 1

echo "Copying first generation..."
cp deltaFiles/generation0/file_* deltaFiles
./runMutationOnly.sh $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} 1

echo "Copying first generation..."
cp deltaFiles/generation0/file_* deltaFiles
./runTournamentOnly.sh $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} 1